/*
 * Qinlan Shen
 * November 8, 2010
 * Pd. 8
 * 
 * Packet created from speed and angle.
 * 
 */

import java.awt.Image;

public class PacketSA extends Packet
{
	protected double speed;
	protected double angle;
	protected double accel;
	protected double angleVel;
	
	public PacketSA(Image i, int h, double xLoc, double yLoc, double s, double a)
	{
		super(i, h, xLoc, yLoc, 0, 0);
		speed = s;
		angle = a;
		xSpeed = speed * Math.sin(Math.toRadians(angle));
		ySpeed = speed * Math.cos(Math.toRadians(angle));
		accel = 0;
		angleVel = 0;
		xAccel = 0;
		yAccel = 0;
	}
	
	public PacketSA(Image i, int h, double xLoc, double yLoc, double s, double a, double tA, double aV)
	{
		super(i, h, xLoc, yLoc, 0, 0);
		img = i;
		hitbox = h;
		x = xLoc;
		y = yLoc;
		speed = s;
		angle = a;
		xSpeed = speed * Math.sin(Math.toRadians(angle));
		ySpeed = speed * Math.cos(Math.toRadians(angle));
		accel = tA;
		angleVel = aV;
		xAccel = accel * Math.sin(Math.toRadians(angle));
		yAccel = accel * Math.cos(Math.toRadians(angle));
	}
	
	public double getSpeed()
	{
		return speed;
	}
	
	public double getAngleAccel()
	{
		return angleVel;
	}
	
	public void setAngle(double a)
	{
		angle = a;
		xSpeed = speed * Math.sin(Math.toRadians(angle));
		ySpeed = speed * Math.cos(Math.toRadians(angle));
		xAccel = accel * Math.sin(Math.toRadians(angle));
		yAccel = accel * Math.cos(Math.toRadians(angle));
	}
	
	public void setAngleVel(int aV)
	{
		angleVel = aV;
	}
	
	public void setSpeed(int s)
	{
		speed = s;
		xSpeed = (int)(speed * Math.sin(Math.toRadians(angle)));
		ySpeed = (int)(speed * Math.cos(Math.toRadians(angle)));
	}
	
	public void setAccel(int a)
	{
		accel = a;
		xAccel = accel * Math.sin(Math.toRadians(angle));
		yAccel = accel * Math.cos(Math.toRadians(angle));
	}
	
	public void update()
	{
		speed += accel;
		angle += angleVel;
		xSpeed = speed * Math.sin(Math.toRadians(angle));
		ySpeed = speed * Math.cos(Math.toRadians(angle));
		xAccel = accel * Math.sin(Math.toRadians(angle));
		yAccel = accel * Math.cos(Math.toRadians(angle));
		x += xSpeed;
		y += ySpeed;
	}
	
}